<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>abcdefg</div>
    <script>
          let pro= prompt("输入内容:");
        let reg= new RegExp(pro,"g");
        console.log(reg);
          let divs =document.querySelector("div");
         divs.innerHTML= divs.innerHTML.replace(reg,value=>{//用正则，将查找到的元素，替换为red
              return `<span style ="color:red">${value}</span>`;
          });

    </script>
</body>
</html>